package com.shop.consts;

/**
 * 订单状态枚举
 * @author ZJL
 * @date 2025/6/5
 */
public enum OrderStatus {
    /**
     * 待支付
     */
    PENDING("pending", "待支付"),

    /**
     * 待发货
     */
    SHIPMENT("shipment", "待发货"),

    /**
     * 已发货
     */
    SHIPPED("shipped", "已发货"),

    /**
     * 已完成
     */
    COMPLETED("completed", "已完成"),

    /**
     * 待评价
     */
    REVIEW("review", "待评价"),

    /**
     * 已取消
     */
    CANCELLED("cancelled", "已取消"),

    /**
     * 售后
     */
    AFTER_SALES("AfterSales", "售后");

    private final String code;
    private final String description;

    OrderStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据状态码获取枚举
     */
    public static OrderStatus fromCode(String code) {
        for (OrderStatus status : OrderStatus.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("未知的订单状态码: " + code);
    }
} 